<?= $this->Html->script('ajax-forms', array('inline'=>false)) ?>

<h1>Kalkulator Registracije vozila</h1>

<?= $this->Form->create('Kalkulator', array(
    'url'   => '/kalkulator/izracunaj',
    'class' => 'ajax-form',
    'id'    => 'kalkulator'
)) ?>
    
    <?= $this->Form->label('vrsta_vozila', 'Vrsta vozila:') ?>
    <?= $this->Form->select('vrsta_vozila', array(
        'putničko' => 'putničko',
        'teretno' => 'teretno',
        'motorcikl' => 'motorcikl'
    ), array(
        'value' => @$data['Kalkulator']['vrsta_vozila'],
        'empty' => false,
        'class' => 'medium',
        'onchange' => 'nosivost()'
    )) ?>
    <span id="nosivost" style="display:none">
        <?= $this->Form->label('nosivost', 'Nosivost:', array('class'=>'inline auto')) ?>
        <?= $this->Form->text('nosivost', array('value' => @$data['Kalkulator']['nosivost'], 'class'=>'small')) ?>
        <span class="label">t</span>
    </span>
    
    <?= $this->Form->label('godiste', 'Godište:') ?>
    <?= $this->Form->select('godiste', $godiste, array(
        'value' => @$data['Kalkulator']['godiste'],
        'empty' => false,
        'class' => 'medium'
    )) ?>
    
    <?= $this->Form->label('snaga', 'Snaga motora:') ?>
    <?= $this->Form->select('snaga', $snaga, array(
        'value' => @$data['Kalkulator']['snaga'],
        'empty' => false,
        'class' => 'medium'
    )) ?> <span class="label">kW</span>
    
    <?= $this->Form->label('zapremina', 'Zapremina motora:') ?>
    <?= $this->Form->text('zapremina', array(
        'value' => @$data['Kalkulator']['zapremina'],
        'class' => 'small',
        'required' => false
    )) ?> <span class="label">cm<sup>3</sup></span>
    <?= $this->Form->error('zapremina') ?>
    
    <? $this->Form->label('tip_motora', 'Tip motora:') ?>
    <? $this->Form->select('tip_motora', $tipovi_motora, array(
        'value' => @$data['Kalkulator']['tip_motora'],
        'empty' => false
    )) ?>
    
    <fieldset>
        <legend>Ostali podaci:</legend>
        <?= $this->Form->checkbox('taxi', array()) ?>
        <?= $this->Form->label('taxi', 'TAXI vozilo?') ?>
        
        <?= $this->Form->checkbox('invalid', array()) ?>
        <?= $this->Form->label('invalid', 'vlasnik invalid preko 80%?') ?>
        
        <?= $this->Form->checkbox('rent_a_car', array()) ?>
        <?= $this->Form->label('rent_a_car', 'Rent-a-Car vozilo?') ?>
        
        <hr>
        <?= $this->Form->checkbox('saobracajna', array()) ?>
        <?= $this->Form->label('saobracajna', 'nova saobraćajna?') ?>
        
        <?= $this->Form->checkbox('tablice', array(
            'style' => 'clear:none'
        )) ?>
        <?= $this->Form->label('tablice', 'nove tablice?') ?>
    </fieldset>
    
    <?= $this->Form->label('premijski_stepen', 'Premijski stepen:') ?>
    <?= $this->Form->select('premijski_stepen', $premijski_stepeni, array(
        'value' => @$data['Kalkulator']['premijski_stepen'],
        'empty' => false,
        'class' => 'medium'
    )) ?>
    
    <?= $this->Form->label('broj_steta', 'Broj šteta:', array('class'=>'inline')) ?>
    <?= $this->Form->select('broj_steta', array(
        0 => 0,
        1 => 1,
        2 => 2,
        3 => 3,
        4 => 4,
        5 => 5
    ), array(
        'value' => @$data['Kalkulator']['broj_steta'],
        'empty' => false,
        'class' => 'small'
    )) ?>
    
<?= $this->Form->submit('Izračunaj') ?>
<?= $this->Form->end() ?>

<script type="text/javascript">
$(function(){
    nosivost();
});

function nosivost() {
    var type = $('#KalkulatorVrstaVozila').val();
    var nosi = $('#nosivost');
    if (type == 'teretno') {
        nosi.show();
    } else {
        nosi.hide();
    }
}
function kalkulator_before(form) {
    $('#kalkulator .form-error').removeClass('form-error');
    $('#kalkulator .error-message').remove()
}
</script>